<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
  <th:block th:include="include :: header('详单')" />
  <th:block th:include="include :: bootstrap-fileinput-css"/>
  <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
  <div class="row">
    <form class="form-horizontal m" id="form-order-edit" th:object="${tudaOrder}">
      <div class="col-sm-4" style="width: 30%;">
        <div class="ibox float-e-margins">
          <div class="ibox-title">
            <h5>订单信息</h5>
          </div>
          <div class="ibox-content">
            <input id="orderId" name="id" th:field="*{id}" type="hidden">
            <input name="userId" th:field="*{userId}" class="form-control" type="hidden" required>
            <div class="form-group">
              <label class="col-sm-3 control-label">提验人：</label>
              <div class="col-sm-8">
                <input name="vehicleInspector" th:field="*{vehicleInspector}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">业务员：</label>
              <div class="col-sm-8">
                <select name="userName" class="form-control">
                  <option th:text="*{userName}"></option>
                  <option th:each="user:${userList}" th:value="${user.userName}+','+${user.phonenumber}" th:text="${user.userName}"></option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">业务员电话：</label>
              <div class="col-sm-8">
                <input name="salesmanPhone" th:field="*{salesmanPhone}" class="form-control" type="number" minlength="11" maxlength="11" disabled>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">车型：</label>
              <div class="col-sm-8">
                <input name="vehicleModel" th:field="*{vehicleModel}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">车架号：</label>
              <div class="col-sm-8">
                <input name="vin" th:field="*{vin}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">委托人：</label>
              <div class="col-sm-8">
                <input name="client" th:field="*{client}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">委托人电话：</label>
              <div class="col-sm-8">
                <input name="clientPhone" th:field="*{clientPhone}" class="form-control" type="number" maxlength="11">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">起始地：</label>
              <div class="col-sm-8">
                <input name="origin" th:field="*{origin}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">目的地：</label>
              <div class="col-sm-8">
                <input name="dest" th:field="*{dest}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">接车人：</label>
              <div class="col-sm-8">
                <input name="receiver" th:field="*{receiver}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">接车人电话：</label>
              <div class="col-sm-8">
                <input name="receiverPhone" th:field="*{receiverPhone}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">运费金额：</label>
              <div class="col-sm-8">
                <input name="freightAmount" th:field="*{freightAmount}" class="form-control" type="number">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">预付款：</label>
              <div class="col-sm-8">
                <input name="paidAmount" th:field="*{paidAmount}" class="form-control" type="number">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">利润：</label>
              <div class="col-sm-8">
                <input name="profit" th:field="*{profit}" class="form-control" type="text">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">支付类型</label>
              <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('pay_type')}">
                  <input type="radio" th:id="${dict.dictCode}" name="payType" th:value="${dict.dictValue}" th:field="*{payType}">
                  <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">订单状态</label>
              <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('order_type')}">
                  <input type="radio" th:id="${dict.dictCode}" name="orderType" th:value="${dict.dictValue}" th:field="*{orderType}">
                  <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label">备注：</label>
              <div class="col-sm-8">
                <input name="notes" th:field="*{notes}" class="form-control" type="text">
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-sm-4" style="width: 70%;">
        <div class="ibox float-e-margins">
          <div class="ibox-title">
            <h5>中转信息</h5>
          </div>
          <div class="ibox-content">
            <div class="row">
              <div class="col-sm-12" >
                <!--                style="table-layout:fixed;word-break:break-all;"-->
                <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                <div class="col-sm-12 select-table table-striped" style=" white-space: nowrap; overflow: hidden; overflow-x: scroll; -webkit-backface-visibility: hidden; -webkit-overflow-scrolling: touch;">
                  <table id="bootstrap-table" style="table-layout:fixed;word-break:break-all;"></table>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-6" style="width: 60%;">
            <div class="ibox float-e-margins">
              <div class="ibox-title">
                <h5>杂费明细</h5>
              </div>
              <div class="ibox-content">
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>提成：</label>
                        <input  type="number" id="commission" name="commission" style="width: 100px;" th:value="${tudaOrder.commission}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="commission_notes" name="commissionNotes" rows="1" style="width: 300px;" maxlength="150" placeholder="请输入内容">[[*{commissionNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="commission_state" th:value="${tudaOrder.commissionState}">
                        <a th:class="${tudaOrder.commissionState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('commission_notes','commission_state','commission','commission')">
                          <div th:text="${tudaOrder.commissionState == 1 ? '结算' : '已结算'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>提验费：</label>
                        <input  type="number" id="inspectionFee" name="inspectionFee" style="width: 100px;" th:value="${tudaOrder.inspectionFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="inspection_notes" name="inspectionNotes" rows="1" style="width: 300px;" maxlength="150" placeholder="请输入内容">[[*{inspectionNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="inspection_state" th:value="${tudaOrder.inspectionState}">
                        <a th:class="${tudaOrder.inspectionState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('inspection_notes','inspection_state','inspectionFee','inspection_fee')">
                          <div th:text="${tudaOrder.inspectionState == 1 ? '结算' : '已结算'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>中介费：</label>
                        <input  type="number" id="agencyFee" name="agencyFee" style="width: 100px;" th:value="${tudaOrder.agencyFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="agency_notes" name="agencyNotes" rows="1" style="width: 300px;" maxlength="150" placeholder="请输入内容">[[*{agencyNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="agency_state" th:value="${tudaOrder.agencyState}">
                        <a th:class="${tudaOrder.agencyState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('agency_notes', 'agency_state', 'agencyFee', 'agency_fee')">
                          <div th:text="${tudaOrder.agencyState == 1 ? '结算' : '已结算'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>代驾费：</label>
                        <input type="number" id="drivingFee" name="drivingFee" style="width: 100px;" th:value="${tudaOrder.drivingFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="driving_notes" name="drivingNotes" rows="1" style="width: 300px;" maxlength="150"  placeholder="请输入内容">[[*{drivingNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="driving_state" th:value="${tudaOrder.drivingState}">
                        <a th:class="${tudaOrder.drivingState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('driving_notes', 'driving_state', 'drivingFee', 'driving_fee')">
                          <div  th:text="${tudaOrder.drivingState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>加油费：</label>
                        <input type="number" id="refuelingFee" name="refuelingFee" style="width: 100px;" th:value="${tudaOrder.refuelingFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="refueling_notes" name="refuelingNotes" rows="1" style="width: 300px;" maxlength="150"  placeholder="请输入内容">[[*{refuelingNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="refueling_state" th:value="${tudaOrder.refuelingState}">
                        <a th:class="${tudaOrder.refuelingState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('refueling_notes', 'refueling_state', 'refuelingFee', 'refueling_fee')">
                          <div  th:text="${tudaOrder.refuelingState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>小板费：</label>
                        <input type="number" id="smallBoardFee" name="smallBoardFee" style="width: 100px;" th:value="${tudaOrder.smallBoardFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="small_board_notes" name="smallBoardNotes" rows="1" style="width: 300px;" maxlength="150"  placeholder="请输入内容">[[*{smallBoardNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="small_board_state" th:value="${tudaOrder.smallBoardState}">
                        <a th:class="${tudaOrder.smallBoardState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('small_board_notes', 'small_board_state', 'smallBoardFee', 'smallBoard_fee')">
                          <div  th:text="${tudaOrder.smallBoardState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>叉车费：</label>
                        <input type="number" id="forkliftFee" name="forkliftFee" style="width: 100px;" th:value="${tudaOrder.forkliftFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="forklift_notes" name="forkliftNotes" rows="1" style="width: 300px;" maxlength="150"   placeholder="请输入内容">[[*{forkliftNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="forklift_state" th:value="${tudaOrder.forkliftState}">
                        <a th:class="${tudaOrder.forkliftState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('forklift_notes', 'forklift_state', 'forkliftFee', 'forklift_fee')">
                          <div  th:text="${tudaOrder.forkliftState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>保险费：</label>
                        <input type="number" id="insureFee" name="insureFee" style="width: 100px;" th:value="${tudaOrder.forkliftFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="insure_notes" name="insureNotes" rows="1" style="width: 300px;" maxlength="150"   placeholder="请输入内容">[[*{insureNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="insure_state" th:value="${tudaOrder.insureState}">
                        <a th:class="${tudaOrder.insureState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('insure_notes', 'insure_state', 'insureFee', 'insure_fee')">
                          <div  th:text="${tudaOrder.insureState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>洗车费：</label>
                        <input type="number" id="carWashFee" name="carWashFee" style="width: 100px;" th:value="${tudaOrder.carWashFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="car_wash_notes" name="carWashNotes" rows="1" style="width: 300px;" maxlength="150"   placeholder="请输入内容">[[*{carWashNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="car_wash_state" th:value="${tudaOrder.carWashState}">
                        <a th:class="${tudaOrder.carWashState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('car_wash_notes', 'car_wash_state', 'carWashFee', 'car_wash_fee')">
                          <div  th:text="${tudaOrder.carWashState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>质损费：</label>
                        <input type="number" id="massLossFee" name="massLossFee" style="width: 100px;" th:value="${tudaOrder.massLossFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="mass_loss_notes" name="massLossNotes" rows="1" style="width: 300px;" maxlength="150"   placeholder="请输入内容">[[*{massLossNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="mass_loss_state" th:value="${tudaOrder.massLossState}">
                        <a th:class="${tudaOrder.massLossState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('mass_loss_notes', 'mass_loss_state', 'massLossFee', 'mass_loss_fee')">
                          <div  th:text="${tudaOrder.massLossState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group" style="margin-bottom:1px;">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label>中转落站：</label>
                        <input type="number" id="transferCarFee" name="transferCarFee" style="width: 100px;" th:value="${tudaOrder.transferCarFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea type="text" id="transfer_notes" name="transferNotes" rows="1" style="width: 300px;" maxlength="150"   placeholder="请输入内容">[[*{transferNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="transfer_state" th:value="${tudaOrder.transferState}">
                        <a th:class="${tudaOrder.transferState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('transfer_notes', 'transfer_state', 'transferCarFee', 'transfer_car_fee')">
                          <div  th:text="${tudaOrder.transferState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
                <div class="form-group">
                  <div class="select-list">
                    <ul>
                      <li>
                        <label >其他费：</label>
                        <input type="number" id="otherFee" name="otherFee" style="width: 100px;" th:value="${tudaOrder.otherFee}"/>
                      </li>
                      <li>
                        <label style="text-align: left; width: 60px;">备注：</label>
                        <textarea id="other_notes" name="otherNotes" maxlength="150" rows="1" style="width: 300px;" placeholder="请输入内容">[[*{otherNotes}]]</textarea>
                      </li>
                      <li>
                        <input type="hidden" id="other_state" name="otherState" th:value="${tudaOrder.otherState}">
                        <a th:class="${tudaOrder.otherState == 1 ? 'btn btn-warning btn-rounded btn-sm' : 'btn btn-primary btn-rounded btn-sm'}" onclick="submitNotes('other_notes', 'other_state', 'otherFee', 'other_fee')">
                          <div  th:text="${tudaOrder.otherState == 1 ? '结清' : '已结清'}"> </div>
                        </a>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="col-sm-6" style="width: 40%;">
            <div class="ibox float-e-margins">
              <div class="ibox-title">
                <h5>车辆图片</h5>
              </div>
              <div class="ibox-content">
                <div th:if="${tudaOrder.carImgList != null}" th:each="imgs,status: ${tudaOrder.carImgList}">
                  <p id="pay-qrcode">
                    <a href="javascript:;">
                      <img th:src="${imgs}"  width="100%">
                    </a>
                  </p>
                </div>
                <div th:if="${tudaOrder.contractImgList != null}" th:each="imgs,status: ${tudaOrder.contractImgList}">
                  <a href="javascript:;" onclick="imageOpen(${imgs})">
                    <img th:src="${imgs}" width="100%">
                  </a>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
  var prefix = ctx + "system/order";

  $("#form-order-edit").validate({
    focusCleanup: true
  });

  function submitHandler() {
    if ($.validate.form()) {
      $.operate.save(prefix + "/renew", $('#form-order-edit').serialize());
    }
  }

  $('#pay-qrcode').click(function(){
    var html=$(this).html();
    parent.layer.open({
      title: false,
      type: 1,
      closeBtn:false,
      shadeClose:true,
      area: ['50%', '50%'],
      content: html
    });
  });

  function submitNotes(name, feeState, amount, feeAmount){
    var fs = $("#"+feeState).val();
    if(fs == 1){
      var orderId = $("#orderId").val();
      var v = $("#"+name).val();
      var money = $("#"+amount).val();
      table.set();
      $.modal.confirm("请确认此费用已结清", function() {
        var url = ctx + "system/finance/updateOrderFee";
        var data = { "orderId": orderId, "feeState": feeState, "feeName":name, "notes":v, "amount":money, "feeAmount": feeAmount };
        $.operate.submit(url, "post", "json", data);
        if($("#"+feeState).val(2)){
          setTimeout( function(){
            window.location.reload();
          }, 1200 );
        }
      });
    }else {
      $.modal.msgSuccess("已结清，请勿重复操作");
    }
  }


  var prefix2 = ctx + "system/finance";
  var refundFlag = [[${@permission.hasPermi('system:finance:refund')}]];

  $(function() {
    var options = {
      refundUrl: prefix2 + "/refund",
      data: [[${tudaOrder.tudaOrderTransferList}]],
      pagination: false,
      showSearch: false,
      showRefresh: false,
      showToggle: false,
      showColumns: false,
      sidePagination: "client",
      columns: [
        { checkbox: true , width: 50},
        { field: 'index', align: 'center', title: "序号", width: 60,
          formatter: function (value, row, index) {
            var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
            return columnIndex + $.table.serialNumber(index);
          }
        },
        { title: '操作', align: 'center', width: 100,
          formatter: function(value, row, index) {
            var actions = [];
            // var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
            if (row.id == null) {
              actions.push('<span class="badge badge-success">无</span>');
              return actions;
            }else{
              if (row.owes == 0) {
                actions.push('<span class="badge badge-success">无</span>');
                return actions;
              }
              if(row.refund){
                actions.push('<a class="btn btn-primary' + refundFlag + '" href="javascript:void(0)">已结清</a>');
                return actions;
              }else {
                if (row.owes > 0) {
                  actions.push('<a class="btn btn-danger' + refundFlag + '" href="javascript:void(0)" onclick="refund(\'' + row.id + '\')">有欠反</a>');
                  return actions;
                }else {
                  actions.push('<a class="btn btn-success' + refundFlag + '" href="javascript:void(0)" onclick="refund(\'' + row.id + '\')">有欠付</a>');
                  return actions;
                }
              }
            }
          }
        },
        { field: 'name', align: 'center', title: '中转地', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].name' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'transitBranch', align: 'center', title: '中转人', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' width='200px;' type='text' name='tudaOrderTransferList[%s].transitBranch' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'transferFee', align: 'center', title: '中转费', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transferFee' id='transferFee' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'owes', align: 'center', title: '欠/返', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].owes' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'amount',  align: 'center', title: '到收款', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='number' name='tudaOrderTransferList[%s].amount' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'plateNumber', align: 'center', title: '车牌号', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].plateNumber' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'transporter',  align: 'center',  title: '驾驶员', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transporter' value='%s'>", index, value);
            return html;
          }
        },

        { field: 'transporterPhone', align: 'center', title: '驾驶员电话', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].transporterPhone' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'notes',  align: 'center', title: '备注', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].notes' value='%s'>", index, value);
            return html;
          }
        },
        { field: 'updateTime',  align: 'center', title: '操作时间', width: 100,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='text' name='tudaOrderTransferList[%s].updateTime' value='%s'>", index, value);
            return html;
          }},
        { field: 'refund', title: '', width: 0,
          formatter: function(value, row, index) {
            var html = $.common.sprintf("<input class='form-control' type='hidden' name='tudaOrderTransferList[%s].refund' value='%s'>", index, value);
            return html;
          }
        },
        ]
    };
    $.table.init(options);
  });

  function addRow() {
    var count = $("#" + table.options.id).bootstrapTable('getData').length;
    var row = {
      index: $.table.serialNumber(count),
      name: "",
      transitBranch: "",
      headPhone: "",
      plateNumber: "",
      transporter: "",
      transporterPhone: "",
      amount: "",
      transferFee: "",
      transitPoint: "",
      notes: "",
    }
    sub.addRow(row);
  }

  function refund (id) {
    table.set();
    $.modal.confirm("请确认信息无误，在确认操作", function() {
      var url = $.common.isEmpty(id) ? table.options.refundUrl : table.options.refundUrl.replace("{id}", id);
      if (table.options.type == table_type.bootstrapTreeTable) {
        $.operate.get(url);
      } else {
        var data = { "id": id };
        var config = {
          url: url,
          type: "post",
          dataType: "json",
          data: data,
          beforeSend: function () {
            $.modal.loading("正在处理中，请稍候...");
          },
          success: function(result) {
            if (typeof callback == "function") {
              callback(result);
            }
            $.operate.ajaxSuccess(result);
            window.location.reload();
          }
        };
        $.ajax(config)
      }
    });
  }

</script>
</body>
</html>